package com.pzr.soccer.utils;



import com.pzr.soccer.domain.game.GameAdditionalInfo;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class GameUtil {

    private static final int required_totalShots = 10, required_gapShots = 5;
    private static final double required_dxQiu = 0.5;


    public static void setAdditionalStringInfo(GameAdditionalInfo gameAdditionalInfo, String contentText) {

        String dangerous_home = "dangerous_home", dangerous_away = "dangerous_away", off_home = "off_home",
                all_attack = "all_attack", off_away = "off_away", on_home = "on_home", on_away = "on_away";

        Pattern pattern = Pattern.compile("(" + all_attack + "\\s+=\\s+)(.*\\]);??");
        Matcher matcher = pattern.matcher(contentText);
        if (matcher.find()) {
            String group2 = matcher.group(2);
            gameAdditionalInfo.setAllAttack(group2);
        }

        // 主队危险进攻
        pattern = Pattern.compile("(" + dangerous_home + "\\s+=\\s+)(.*\\]);??");
        matcher = pattern.matcher(contentText);
        if (matcher.find()) {
            String group2 = matcher.group(2);
            gameAdditionalInfo.setHomeDangerous(group2);
        }

        // 客队危险进攻
        pattern = Pattern.compile("(" + dangerous_away + "\\s+=\\s+)(.*\\]);??");
        matcher = pattern.matcher(contentText);
        if (matcher.find()) {
            String group2 = matcher.group(2);
            gameAdditionalInfo.setAwayDangerous(group2);
        }

        // 客队射偏
        pattern = Pattern.compile("(" + off_home + "\\s+=\\s+)(.*\\]);??");
        matcher = pattern.matcher(contentText);
        if (matcher.find()) {
            String group2 = matcher.group(2);
            gameAdditionalInfo.setHomeShotOff(group2);
        }

        // 客队射正
        pattern = Pattern.compile("(" + on_away + "\\s+=\\s+)(.*\\]);??");
        matcher = pattern.matcher(contentText);
        if (matcher.find()) {
            String group2 = matcher.group(2);
            gameAdditionalInfo.setAwayShotOn(group2);
        }

        // 主队射偏
        pattern = Pattern.compile("(" + off_away + "\\s+=\\s+)(.*\\]);??");
        matcher = pattern.matcher(contentText);
        if (matcher.find()) {
            String group2 = matcher.group(2);
            gameAdditionalInfo.setAwayShotOff(group2);
        }

        // 主队射正
        pattern = Pattern.compile("(" + on_home + "\\s+=\\s+)(.*\\]);??");
        matcher = pattern.matcher(contentText);
        if (matcher.find()) {
            String group2 = matcher.group(2);
            gameAdditionalInfo.setHomeShotOn(group2);
        }
    }
}
